/*------------------------------------------------------------------------------
 * Copyright 2012 NCR Corporation
 *------------------------------------------------------------------------------
 * All revision information is updated automatically from source code control
 * change records - please do not manually edit.
 *------------------------------------------------------------------------------
 *
 *  $LastChangedRevision::                                          $
 *  $LastChangedBy::                                                $
 *  $LastChangedDate::                                              $
 */

package com.ncr.nep.dashboardcore.ui.client;

import com.google.gwt.event.dom.client.MouseEvent;
import com.google.gwt.user.client.ui.IsWidget;
import com.google.web.bindery.event.shared.Event;

/**
 * Event dispatched by the {@link DragManager} when the mouse is moved over
 * an object/element during a drag operation.
 * 
 * @author rb250096
 * @version $Revision$
 */
public class DragOverEvent extends Event<DragOverHandler> {

    //--------------------------------------------------------------------------
    //
    //  Fields
    //
    //--------------------------------------------------------------------------

    /**
     * The event type.
     */
    public static final Type<DragOverHandler> TYPE =
            new Type<DragOverHandler>();

    /**
     * The item being dragged.
     */
    protected IsWidget dragSource;

    /**
     * The item being dragged over.
     */
    protected IsWidget dropTarget;

    /**
     * The mouse event containing latest info about the drag.
     */
    protected MouseEvent<?> mouseEvent;

    //--------------------------------------------------------------------------
    //
    //  Constructors
    //
    //--------------------------------------------------------------------------

    /**
     * Constructor
     *
     * @param dragSource The item being dragged around screen.
     * @param dropTarget The item dragged over.
     * @param mouseEvent The mouse event associated with this event.
     */
    public DragOverEvent(IsWidget dragSource, IsWidget dropTarget,
                         MouseEvent<?> mouseEvent) {
        super();
        this.dragSource = dragSource;
        this.dropTarget = dropTarget;
        this.mouseEvent = mouseEvent;
    }

    //--------------------------------------------------------------------------
    //
    //  Properties
    //
    //--------------------------------------------------------------------------
    
    @Override
    public Type<DragOverHandler> getAssociatedType() {
        return TYPE;
    }

    /**
     * Gets the item being dragged.
     *
     * @return The item being dragged.
     */
    public IsWidget getDragSource() {
        return dragSource;
    }

    /**
     * Gets the item that was dragged over.
     *
     * @return The item dragged over.
     */
    public IsWidget getDropTarget() {
        return dropTarget;
    }

    /**
     * Gets the mouse event associated with this event.
     *
     * @return The mouse event.
     */
    public MouseEvent<?> getMouseEvent() {
        return mouseEvent;
    }

    //--------------------------------------------------------------------------
    //
    //  Methods
    //
    //--------------------------------------------------------------------------

    @Override
    protected void dispatch(DragOverHandler dragOverHandler) {
        dragOverHandler.onDragOver(this);
    }
}
